import request from '@/utils/request'

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{
 *   dataSourceName: string;
 *   dataSourceType: string;
 *   dataSourceDesc: string;
 *   address: string;
 *   port: string;
 *   userName: string;
 *   password: string;
 *   databaseName: string;
 *   connectExtInfo: string;
 *   minPoolSize: number;
 *   maxPoolSize: number;
 *   queryTimeout: number;
 * }} params
 * @return {*}  {ResponseResult<string>}
 */
export async function addDataSource(params) {
  return request.post(`/v1/datasource/add`, params);
}

export async function deleteDataSourceById(datasourceId) {
  return request.delete(`/v1/datasource/delete/${datasourceId}`);
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{
 *   id: number;
 *   dataSourceName: string;
 *   dataSourceType: string;
 *   dataSourceDesc: string;
 *   address: string;
 *   port: string;
 *   userName: string;
 *   password: string;
 *   databaseName: string;
 *   connectExtInfo: string;
 *   minPoolSize: number;
 *   maxPoolSize: number;
 *   queryTimeout: number;
 * }} params
 * @return {*}  {ResponseResult<boolean>}
 */
export async function updateDataSourceById(params) {
  return request.put(`/v1/datasource/update`, params);
}

export async function queryDataSourceInfo(dataSourceId) {
  return request.get('/v1/datasource/info/' + dataSourceId);
}

export async function dataSourceList() {
  return request.get('/v1/datasource/list');
}

/**
 * @description
 * @author Golduck
 * @date 06/05/2025
 * @export
 * @param {{ pageNum: number; pageSize: number }} params
 * @return {*}  {ResponsePageResult}
 */
export async function dataSourcePage(params) {
  return request.post('/v1/datasource/page', params);
}

export async function connectDataSource(dataSourceId) {
  return request.get('/v1/datasource/connect/' + dataSourceId);
}
